package com.newer.his.BasicData.controller;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.newer.his.common.entity.AdviceType;
import com.newer.his.common.mapper.AdviceTypeMapper;

/**
 * 医嘱类型控制器
 * @author Tang
 *
 */

@RestController
@RequestMapping("/advicetype")
public class AdviceTypeController {
	
	 @Autowired
	 AdviceTypeMapper adviceTypeMapper;

	    @GetMapping
	    public List<AdviceType> getAllAdviceType() {
	        return adviceTypeMapper.findAll();
	    }
	    @GetMapping("/{id}")
	    public AdviceType getAdviceTypeById(@PathVariable int id) {
	        return adviceTypeMapper.findbyId(id);
	    }

	    @PostMapping
	    public AdviceType addAdviceType(AdviceType adviceType ){
	    	adviceTypeMapper.save(adviceType);
	        return adviceType;
	    }

	    @PutMapping("/{id}")
	    public void updateEmployee(
	    		@PathVariable int id,
	    		@RequestBody AdviceType adviceType) {
	    	adviceType.setId(id);
	    	adviceTypeMapper.update(adviceType);
	        
	    }
	 // DELETE '/xxx/id'
    @DeleteMapping("/{id}")
    public void deleteAdviceType(@PathVariable int id) {
	    	adviceTypeMapper.delete(id);
    }
	

	

}
